package cn.calm.message.result.listener;

import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceReference;

import cn.calm.entity.Message;
import cn.calm.message.service.IMessageService;

import com.opensymphony.xwork2.interceptor.PreResultListener;

public class Activator implements BundleActivator {
	public static BundleContext context;

	@SuppressWarnings({ "rawtypes", "unchecked" })
	@Override
	public void start(BundleContext arg0) throws Exception {
		context = arg0;
		MessageListener listener = new MessageListener();
		ServiceReference<IMessageService> serviceRef = context
				.getServiceReference(IMessageService.class);
		if(serviceRef!=null){
			IMessageService<Message> service=context.getService(serviceRef);
			listener.setService(service);
			
			arg0.registerService(PreResultListener.class.getName(), listener, null);
		}
		
	}

	@Override
	public void stop(BundleContext arg0) throws Exception {

	}

}
